#include "menu.h"

GtkWidget* create_menu_bar() {
    GtkWidget *menu_bar;
    GtkWidget *file_menu;
    GtkWidget *edit_menu;
    GtkWidget *view_menu;
    GtkWidget *help_menu;
    GtkWidget *quit_menu;
    GtkWidget *file_submenu;  // New menu to hold "退出" item

    menu_bar = gtk_menu_bar_new();

    file_menu = gtk_menu_item_new_with_label("文件");
    quit_menu = gtk_menu_item_new_with_label("退出");
    edit_menu = gtk_menu_item_new_with_label("编辑");
    view_menu = gtk_menu_item_new_with_label("视图");
    help_menu = gtk_menu_item_new_with_label("帮助");

    // Create a submenu for "文件"
    file_submenu = gtk_menu_new();
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(file_menu), file_submenu);
    gtk_menu_shell_append(GTK_MENU_SHELL(file_submenu), quit_menu);

    g_signal_connect(quit_menu, "activate", G_CALLBACK(gtk_main_quit), NULL);

    gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file_menu);
    gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), edit_menu);
    gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view_menu);
    gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help_menu);

    return menu_bar;
}